#include "CHero.h"
#include "SGD Wrappers/CSGD_Direct3D.h"
#include "SGD Wrappers/CSGD_TextureManager.h"
#include "CObjectManager.h"
#include "SGD Wrappers/CSGD_DirectInput.h"
#include "CGame.h"
#include "CUnit.h"
#include "SGD Wrappers/SGD_Math.h"
#include "Mail System.h"
#include "Deliverables.h"

CHero::CHero()
{
	m_nType = HERO;
	m_nHeroType = HERO_MAX;
}
CHero::~CHero()
{

}
void CHero::Init()
{

}
void CHero::Update(float fDelta)
{
	float posX = GetPosX();
	float posY = GetPosY();
	if(CSGD_DirectInput::GetInstance()->KeyDown(DIK_W) && GetPosY() >= 0)
	{
		posY -= 20 * fDelta;
	}
	if(CSGD_DirectInput::GetInstance()->KeyDown(DIK_S) && GetPosY() + GetHeight() <= CGame::GetInstance()->GetScreenHeight())
	{
		posY += 20 * fDelta;
	}
	if(CSGD_DirectInput::GetInstance()->KeyDown(DIK_A) && GetPosX() >= 0)
	{
		posX -= 20 * fDelta;
	}
	if(CSGD_DirectInput::GetInstance()->KeyDown(DIK_D) && GetPosX() + GetWidth() <= CGame::GetInstance()->GetScreenWidth())
	{
		posX += 20 * fDelta;
	}
	if(CSGD_DirectInput::GetInstance()->KeyPressedEx(DIK_1))
	{
		MailSystem::GetInstance()->SendMail(new SpawnUnit(this));
	}
	SetPosX(posX);
	SetPosY(posY);
}
void CHero::Render()
{
	RECT temp;
	temp.top = (LONG)GetPosY();
	temp.bottom = temp.top + 50;
	temp.left = (LONG)GetPosX();
	temp.right = temp.left + 50;
	CSGD_Direct3D::GetInstance()->SpriteEnd();
	CSGD_Direct3D::GetInstance()->DrawRect(temp, 255,0,0);
	CSGD_Direct3D::GetInstance()->SpriteBegin();
}